package arrayList;

import com.sun.source.tree.ReturnTree;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2025-08-21
 * Time: 21:51
 */
public class MyArrayList {

    static class ListNode {
        int val;
        ListNode  next;

        public ListNode(int val){
            this.val = val;
        }
    }

    public ListNode head;

    public ListNode createList(){
        ListNode node1 = new ListNode(12);
        ListNode node2 = new ListNode(23);
        ListNode node3 = new ListNode(34);
        ListNode node4 = new ListNode(45);
        ListNode node5 = new ListNode(56);

        node1.next = node2;
        node2.next = node3;
        node3.next = node4;
        node4.next = node5;

        head = node1;

        return head;
    }

    public void show(){
        ListNode cur = head;
        while (cur != null){
            System.out.print(cur.val + " ");
            cur = cur.next;
        }
    }

    public void size(){
        ListNode cur = head;
        int count = 0;
        while(cur!=null){
            cur = cur.next;
            count++;
        }
        System.out.println(count);
    }

    public boolean contains(int x){
        ListNode cur = head;
        while (cur != null){
            if (cur.val == x){
                return true;
            }
            cur  = cur.next;
        }
        return false;
    }
    public void addIndex(int val){
        if (head == null)



    }

}
